home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10622 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  953 b 

  1. Path: condor.navsses.navy.mil!mdipilla
  2. From: mdipilla@condor.navsses.navy.mil
  3. Newsgroups: comp.lang.c
  4. Subject: Help!  Initializing a C string
  5. Message-ID: <1996Mar18.095842.2435@condor>
  6. Date: 18 Mar 96 09:58:42 -0600
  7. Organization: CDNSWC, Naval Ship Systems Eng Sta, Phila PA
  8.  
  9. to whom is all C' knowing...
  10.  
  11.     I have a string which is formulating by several lines from an input file.
  12. The approach we hae taken is to do a strncpy of the first line and then
  13. strncat of each additional line.
  14.  
  15.     When the string is formed we need to null it out so we can read the next
  16. string in.
  17.  
  18.     The problem we are having is that if we set the string to "\0"
  19. we 
  20.  
  21.       1. Overwrite the first line (strcpy)
  22.       2. However the 2nd, 3rd, 4th, etch lines of the string are concatenated
  23. after the initial string that wwas written.
  24.  
  25.  how do you INIitialze the variable  of the string so it is clear and you
  26. do not have this overwrite problem.
  27.  
  28. Michael
  29. (215) 897-1051
  30.  
  31.  
  32.